package com.seahorse.youliao.service.impl;

import com.seahorse.youliao.service.entity.User;
import com.seahorse.youliao.service.UserService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

/**
 * @ProjectName: youliao
 * @Package: com.seahorse.youliao.impl
 * @ClassName: SysUserServiceImpl
 * @Description: 用户管理实现
 * @author:songqiang
 * @Date:2020-01-10 11:10
 **/
@Service
public class UserServiceImpl implements UserService {


    @Override
    public User findByUsername(String username) {
        if(!username.equals("admin")){
            return null;
        }
        User user = new User();
        user.setId(1L);
        user.setUsername(username);
        String password = new BCryptPasswordEncoder().encode("123");
        user.setPassword(password);
        return user;
    }

    @Override
    public Set<String> findPermissions(String username) {
        Set<String> permissions = new HashSet<>();
        permissions.add("sys:user:view");
        permissions.add("sys:user:add");
        permissions.add("sys:user:edit");
        permissions.add("sys:user:delete");
        return permissions;
    }
}
